package com.yanqu.road.server.cmd.beauty;

import com.yanqu.road.pb.beauty.BeautyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_BEAUTY_CHOOSE_VOICE,desc = "美女选择语音")
public class BeautyChooseVoiceCmd extends AbstractCommand {

    private int beautyId;

    private int voiceId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BeautyProto.chooseVoiceReqMsg reqMsg = BeautyProto.chooseVoiceReqMsg.parseFrom(packet.getBytes());
        beautyId =  reqMsg.getBeautyId();
        voiceId = reqMsg.getVoiceId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(BeautyModule.class).beautyChooseVoice(beautyId,voiceId);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret!=0){
            BeautyProto.chooseVoiceRespMsg.Builder builder = BeautyProto.chooseVoiceRespMsg.newBuilder();
            builder.setRet(ret);
            player.sendPacket(ClientProtocol.U_BEAUTY_CHOOSE_VOICE,builder);
        }
    }
}
